package cn.itcast.rnk.design.patterns;

import java.util.Date;

public class IntermediaryPattern {

	public static void main(String[] args) {
		testIntermediaryPattern();
	}

	private static void testIntermediaryPattern() {
		
		   User young = new User("Young");
		   User youngyoung = new User("YoungYoung");
		   
		   
		   young.sendMessage("Hi ! YoungYoung");
		   youngyoung.sendMessage("Hi! Young");
	}

}

class ChatRoom {
	public static void showMessage(User user, String message) {
		System.out.println(new Date().toString() + "[ " + user.getName() + " ]:" + message);
	}

}

class User {
	private String name;

	public User(String name) {
		this.name = name;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public void sendMessage(String message) {
		ChatRoom.showMessage(this, message);
	}
}